$(function(){
	$('.floatimgalbum img').load(function(){
		imgZoomInit();
	})
	function imgZoomInit(){
		$('.mark').mouseenter(function(){
			// if($(this).offset().left < ($(window).width()/2) ){
			// }else{
			// 	$(this).find('.album_zooms_container').addClass('right-item');
			// }
			$('.album_zooms_handle').css('display','block');
			$('.album_zooms_container').css('display','block');
		})
		$('.mark').mouseleave(function(){
			$('.album_zooms_handle').css('display','none');
			$('.album_zooms_container').css('display','none');
		})
		var l = $('.mark').offset().left;
		var t = $('.mark').offset().top;
		$('.mark').mousemove(mousefollowfun);
		function mousefollowfun(e){
			e.stopPropagation();
			var x = e.pageX - l - $('.album_zooms_handle').width()/2;
			var y = e.pageY - t - $('.album_zooms_handle').height()/2;
			if(x<=0){													//限制小滑块可移动范围					
				x = 0;
			}else if(x >= $('.mark').width()-$('.album_zooms_handle').width()){
				x = $('.mark').width()-$('.album_zooms_handle').width();
			}
			if(y<=0){
				y = 0;
			}else if(y >= $('.mark').height()-$('.mark').siblings('.album_zooms_handle').height()){
				y = $('.mark').height()-$('.mark').siblings('.album_zooms_handle').height();
			}
			$('.album_zooms_handle').css({'left':x+'px','top':y+'px'})
			var X = x/($('.mark').width()-$('.mark').siblings('.album_zooms_handle').width());
			var Y = y/($('.mark').height()-$('.mark').siblings('.album_zooms_handle').height());
			$('.album_zooms_container').find('.album_bigimg').css({
				'left':-X*($('.mark').siblings('.album_zooms_container').width()-$('.mark').siblings('.album_bigimg').width()),
				'top':Y*($('.mark').siblings('.album_zooms_container').height()-$('.mark').siblings('.album_zooms_container').find('.album_bigimg').height())
			});
		}
	}
})